package com.deco.service.brand;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.deco.domain.vo.brand.ActivityReportVo;
import com.deco.logic.brand.ActivityReportLogic;
import com.deco.service.CommonService;
import com.free.common.vo.PageResponseVo;
import com.free.common.vo.PageSearchVo;
import com.free.common.vo.ResultModel;

@Service
public class ActivityReportService extends CommonService {
	   /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/
    
    @Autowired
    private ActivityReportLogic activityReportLogic;
    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/

    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/

    
    public ActivityReportVo getActivityReport(long id){
    	return activityReportLogic.getActivityReport(id);
    }
    
    public ResultModel save(ActivityReportVo activityReportVo){
    	Date current = new Date();
		int currentUserId = getCurrentUserId();
    	
    	if(activityReportVo.getId() == null || activityReportVo.getId() == 0L){
    		activityReportVo.setCreateBy(currentUserId);
    		activityReportVo.setCreateTime(current);
    		activityReportVo.setUpdateBy(currentUserId);
    		activityReportVo.setUpdateTime(current);
    		activityReportLogic.create(activityReportVo);
    	}
    	else{
    		activityReportVo.setUpdateBy(currentUserId);
    		activityReportVo.setUpdateTime(current);
    		activityReportLogic.update(activityReportVo);
    	}
    	return ResultModel.success();
    }

	public ResultModel delete(Long id) {
		activityReportLogic.delete(id);
	  	return ResultModel.success();
	}

	public PageResponseVo<ActivityReportVo> pageInfo(
			PageSearchVo<ActivityReportVo> condition) {
		return activityReportLogic.getPageInfo(condition);
	}

	public ResultModel batchDelete(String[] idArray) {
		activityReportLogic.batchDelete(idArray);
		return ResultModel.success();
	}

	public List<String> getActivityReportYears(){
    	return activityReportLogic.getActivityReportYears();
	}

	public List<ActivityReportVo> getYearReports(String year) {
    	return activityReportLogic.getYearReports(year);
	}
    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/

}
